import Vue from "vue";
import App from "./App";
import request from "@/util/request";
import { $http } from "@escook/request-miniprogram";

Vue.config.productionTip = false;

App.mpType = "app";

// 挂载http
uni.$http = $http;
$http.baseUrl = "https://api-hmugo-web.itheima.net";
$http.beforeRequest = (options) => {
    uni.showLoading({
        title: "正在加载中...",
    });
};
$http.afterRequest = (options) => {
    uni.hideLoading();
};

// 绑定提示框
uni.$showMsg = function(text = "已无更多数据") {
    uni.showToast({
        title: text,
        icon: "none",
    });
};

// 将封装的promise 挂在再vue的原型链上
Vue.prototype.request = request;

const app = new Vue({
    ...App,
});
app.$mount();